/*
 * To change this template, choose Tools | Templates and open the template in the editor.
 */
package parser.part.n3;

import java.util.HashMap;
import java.util.List;

/**
 * @version aka worker
 * @author Patronus
 */
public class Executor {

    List<ConditionContainer> tree;
    HashMap<String, Object> results;//results for each step

    /**
     * 
     * @param l
     */
    public Executor(List l) {
        this.tree = l;
    }

    void execute() {
        for (int possition = 0; possition < tree.size();) {
            ConditionContainer e = tree.get(possition);
            executeRule(e.getRule());
            boolean conditionValue = checkCondition(e.getCondition());
            possition = getNext(conditionValue, possition);

        }
    }
    /*
     * will check condition
     */

    private boolean checkCondition(String condition) {
        return true;
    }
    /*
     * execute and save to table
     */

    private void executeRule(Ruler r) {
        //для контейнера!
//        if (r.needResult) {
//            results.put(r.getId(), r.exequteRule());
//        }
    }
    /*
     * get next element in tree
     */

    private int getNext(boolean state, int currentPosition) {
        return (state) ? 2 * currentPosition + 1 : 2 * currentPosition;
    }
}
